package cn.huanzi.qch.baseadmin.travel.reservation.controller;

import cn.huanzi.qch.baseadmin.common.controller.CommonController;
import cn.huanzi.qch.baseadmin.common.pojo.Result;
import cn.huanzi.qch.baseadmin.travel.reservation.pojo.Reservation;
import cn.huanzi.qch.baseadmin.travel.reservation.service.ReservationService;
import cn.huanzi.qch.baseadmin.travel.reservation.vo.ReservationVO;
import cn.huanzi.qch.baseadmin.travel.thotel.pojo.THotel;
import cn.huanzi.qch.baseadmin.travel.thotel.service.THotelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.UUID;


/**
 * 预约管理
 */

@Slf4j
@RestController
@RequestMapping("/travel/hotel/reservation")
public class ReservationController extends CommonController<ReservationVO, Reservation, Integer> {

    @Autowired
    private ReservationService reservationService;

    @Autowired
    private THotelService tHotelService;

    @GetMapping
    public ModelAndView findHotelByID(@RequestParam Integer id, ModelAndView modelAndView) {
        THotel hotel = tHotelService.findByHotelID(id);
        modelAndView.addObject("hotelByID", hotel);
        modelAndView.setViewName("travel/front-end/reservation");

        return modelAndView;
    }

    @GetMapping("/")
    public ModelAndView toReservation(){
        return new ModelAndView("travel/reservation/reservation");
    }

    @PostMapping("/save")
    @Override
    public Result<ReservationVO> save(ReservationVO entityVo) {
        entityVo.setReservationId(1);
        return super.save(entityVo);
    }
}
